package com.briup.server.web.controller;

import com.briup.common.response.Result;
import com.briup.server.domain.bean.User;
import com.briup.server.domain.dto.LabsAssignAdminDTO;
import com.briup.server.service.LabsAdminRService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Tag(name = "实验室管理员相关接口")
@RestController
@RequestMapping("/labs/admin")
@RequiredArgsConstructor
public class LabsAdminController {
    private final LabsAdminRService service;

    @Operation(summary = "查询所有可用的实验室管理员")
    @GetMapping("/list")
    public Result<List<User>> listLabsAdmins() {
        List<User> users = service.queryListEnabled();
        return Result.success(users)
                .apply("获取成功");
    }

    @Operation(summary = "分配实验室管理员")
    @PostMapping("/assign-admin")
    public Result<?> assignAdmin(@RequestBody @Valid
                                 LabsAssignAdminDTO assignAdminDTO) {
        service.assignAdmin(assignAdminDTO);
        return Result.success();
    }
}
